const fs   = require('fs');

function writeFile(path,data) {
    fs.writeFileSync(path,data);
}

function writeFileBinary(path,data) {
    fs.writeFileSync(path,data,'binary');
}

function readFile(path) {
    if(!exists(path)){
        return null;
    }
    return fs.readFileSync(path,'utf8');
}

function readFileBinary(path) {
    if(!exists(path)){
        return null;
    }
    return fs.readFileSync(path,'binary');
}

function exists(path) {
    return fs.existsSync(path);
}

module.exports = {
    writeFile:writeFile,
    readFile:readFile,
    exists:exists,
    readFileBinary:readFileBinary,
    writeFileBinary:writeFileBinary
}
